/**
 * 2016年9月22日
 */
package algorithm.CIG;

/**
 * @author Alex
 *
 */
public class BaseExp {

	    public double Power(double base, int exponent) {
	        return get(base,exponent);
	  }
	    
	    
	    public double get(double base,int ex){
	        if(ex==0) return 1;
	        if(ex==1) return base;

	        double res = get(base,ex>>1);
	        res *= res;
	        if((ex & 0x1)==1){
	             res*=base;
	        }
	        return res;
	        
	    }
	       
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		System.out.println(new BaseExp().Power(2, 3));
	}

}
